//
//  RLChartMenuItem.m
//  MacStockApp
//
//  Created by 英傑 翁 on 12/6/4.
//  Copyright (c) 2012年 翁英傑. All rights reserved.
//

#import "RLChartMenuItem.h"
#import "GBChartMenuItem_ObjectOtherKey.h"
#import "GBChartMenuItem_indicator.h"
#import "GBChartMenuItem_signal.h"
#import "GBChartMenuItem_fundemental.h"
#import "GBChartMenuItem_choma.h"
#import "GBCalculationMethod_commonIndicator.h"
#import "GBCalculationMethod_selfIndicator.h"
#import "GBCalculationMethod_noCalculate.h"
#import "GBTableColumnHeader_key.h"
#import "GBChartMenuItem_key.h"
#import "GBTableColumnHeader_Indicator.h"  
#import "GBTableColumnHeader_signal.h" 
#import "GBall.h"
#import "DHxlsReaderIOS.h"

@implementation RLChartMenuItem

@synthesize RLChartMenuItem_array_A ;
@synthesize RLChartMenuItem_data_file_path;
 
- (id)init_datasource:(NSString *)ds {
	
    if(self=[super init])
	{
       
        
       // RLChartMenuItem_array=[[NSMutableArray alloc] init];
        
        datasource=ds;
        
        
        //存放路徑位置與檔名  
        RLChartMenuItem_data_file_path=[[File_Name_Path RLChartMenuItem_file_nameANDpath:datasource] retain];
            
        
        
        NSFileManager *fileManager = [NSFileManager defaultManager];  
        BOOL success = [fileManager fileExistsAtPath:RLChartMenuItem_data_file_path];
        
        //判斷是否有觀察名單檔案
        if (success) {
            
            [self setRLChartMenuItem_array_A:[NSArray arrayWithContentsOfFile:RLChartMenuItem_data_file_path]];
            
           
            
            
        }
        else  {
            
            //取得資料庫在資源裏面的路徑
            NSString *resourcePath= [[NSBundle mainBundle] pathForResource:[File_Name_Path RLChartMenuItem_file_name:datasource add_plist:NO] ofType:@"plist"]; 	
            
            
            BOOL success_resource = [fileManager fileExistsAtPath:resourcePath];            
            if (success_resource ) {
                 NSLog(@"ccccc資源檔有此檔案");
                
                //存資源檔拷貝檔案至document
                [fileManager copyItemAtPath:resourcePath toPath:RLChartMenuItem_data_file_path error:nil];                 
                //取出資料
                [self setRLChartMenuItem_array_A:[NSArray arrayWithContentsOfFile:RLChartMenuItem_data_file_path]];
                
            }
            else {
                
               
                NSLog(@"ccccc資源檔無此檔案 所以從頭建立 此處可以用來作為首次建立plist使用");
                
                //取出全部資料
                [self setRLChartMenuItem_array_A:[self get_all_table_column_RLCM]];
               
                
                
            }
            
            //將資料庫檔案從resourcePath 拷貝到theInstance.databasePath
            //           
            
            
            
        }
        
        
        
        //檢查table_column_array是不是有遺漏
        {
            //取出全部應該有的欄位資料
            NSMutableArray *all_table_column=[self get_all_table_column_RLCM];
            
            //逐一檢查並且加入缺少的key
            for (NSMutableDictionary *atc in all_table_column  ) {
                NSString *alltkey=[atc objectForKey:Chart_Data_hisdata_calculate_method];
                
                if ([self index_calculatemethod_array_from_column_identfiler:alltkey]==NSNotFound) {
                    //將缺少的key加入
                    [RLChartMenuItem_array_A addObject:atc];
                    
                    
                }
            }        
        }
        
        //存檔
        [self save_data:RLChartMenuItem_array_A];
         
        
        //轉化方法存入
        [RLChartMenuItem have_to_calcultae_method];
    }
	
	return self;
}

#pragma mark -
#pragma mark 取出所有欄位屬性資料

 

-(NSMutableArray *)get_all_table_column_RLCM{
    //從excel取回 資料 還原字典
    NSMutableArray *retdic=[[[NSMutableArray alloc] init] autorelease];
    {
        
        //1.取得資料庫在資源裏面的路徑
        NSString *resourcePath;
        {
            resourcePath= [[NSBundle mainBundle] pathForResource:[File_Name_Path file_name_RLChartMenuItem] ofType:@"xls"];
          
            NSLog(@"存放資源檔的位置:%@" ,resourcePath);
            
        }
        
        //2.excel 讀檔
        DHxlsReader *reader = [DHxlsReader xlsReaderFromFile:resourcePath];
        
        
        //3.檔案基本資料
        {
            /*
             NSString *text = @"";
             
             text = [text stringByAppendingFormat:@"AppName: %@\n", reader.appName];
             text = [text stringByAppendingFormat:@"Author: %@\n", reader.author];
             text = [text stringByAppendingFormat:@"Category: %@\n", reader.category];
             text = [text stringByAppendingFormat:@"Comment: %@\n", reader.comment];
             text = [text stringByAppendingFormat:@"Company: %@\n", reader.company];
             text = [text stringByAppendingFormat:@"Keywords: %@\n", reader.keywords];
             text = [text stringByAppendingFormat:@"LastAuthor: %@\n", reader.lastAuthor];
             text = [text stringByAppendingFormat:@"Manager: %@\n", reader.manager];
             text = [text stringByAppendingFormat:@"Subject: %@\n", reader.subject];
             text = [text stringByAppendingFormat:@"Title: %@\n", reader.title];
             
             text = [text stringByAppendingFormat:@"\n\nNumber of Sheets: %ld\n", reader.numberOfSheets];
             
             NSLog(@"檔案基本資料：%@",text);
             */
            
        }
        
        //4.sheets 資料
        {
            
            
            for (int i=0; i< reader.numberOfSheets ; i++) {
                
                // NSString *sheetname=[reader sheetNameAtIndex:i] ;
                
                // NSLog(@"sheet name=%@",sheetname);
                
            }
            
            
        }
        
        //5.取出第一個sheet 資料 並做成陣列資料
        int sheetIndex=0;
        {
            //取出dic_key excel 行標題
            NSMutableArray *dic_key_array=[[[NSMutableArray alloc] init] autorelease];
            {
                
                int row = 4; //開始的行位置
                
                while(YES) {
                    
                    //中斷檢查用
                    DHcell *cell_check  = [reader cellInWorkSheetIndex:sheetIndex row:row col:3];
                    if(cell_check.type == cellBlank) break;
                    
                    //如果col:1有資料 就取出同一row資料
                    DHcell *cella  = [reader cellInWorkSheetIndex:0 row:row col:3];
                    
                    
                    [dic_key_array addObject:[cella str]];
                    
                    row++;
                    
                    
                }
                
                // NSLog(@"dic_key_array=%@",dic_key_array );
            }
            
            
            
            //取出dic_sub_key excel 列標題 與屬性
            NSMutableArray *dic_sub_key=[[[NSMutableArray alloc] init] autorelease];
            {
                int coll=2; //開始的列位置
                
                while(YES) {
                    
                    //中斷檢查用
                    DHcell *cell_check  = [reader cellInWorkSheetIndex:sheetIndex row:2 col:coll];
                    if(cell_check.type == cellBlank) break;
                    
                    //如果col:1有資料 就取出同一row資料
                    DHcell *cellrow1  = [reader cellInWorkSheetIndex:0 row:2 col:coll];
                    DHcell *cellrow2  = [reader cellInWorkSheetIndex:0 row:3 col:coll];
                    
                    NSMutableDictionary *dicp=[[NSMutableDictionary alloc] init] ;
                    [dicp setObject:[cellrow1 str] forKey:@"dic_sub_key"];
                    [dicp setObject:[cellrow2 str] forKey:@"dic_sub_pro"];
                    [dic_sub_key addObject:dicp];
                    [dicp release];
                    //  NSLog(@"%@/%@ ", [cellrow1 str],[cellrow2 str] );
                    
                    
                    
                    
                    
                    coll++;
                    
                    
                }
                
                //NSLog(@"dic_sub_key=%@",dic_sub_key );
            }
            
            
            // 進入excel資料內 建制複製還原
            for (int row=0; row<[dic_key_array count]; row++) {
                
                
                NSMutableDictionary *subdic=[[NSMutableDictionary alloc] init];
                {
                    for (int col=0; col<[dic_sub_key count]; col++) {
                        NSMutableDictionary *sss=[dic_sub_key objectAtIndex:col];
                        
                        NSString *subkey=[sss objectForKey:@"dic_sub_key"];
                        NSString *subpro=[sss objectForKey:@"dic_sub_pro"];
                        
                        //excel 資料
                        DHcell *cell_value  = [reader cellInWorkSheetIndex:sheetIndex row:row+4 col:col+2];
                        
                        if ([subpro isEqualToString:@"__NSCFNumber"]) {
                            float fvalue= [[cell_value str] floatValue];
                            
                            [subdic setObject:[NSNumber numberWithFloat:fvalue]  forKey:subkey];
                            
                            
                        }
                        else if ([subpro isEqualToString:@"__NSCFBoolean"]) {
                            BOOL bvalue= [[cell_value str] boolValue];
                            
                            [subdic setObject:[NSNumber numberWithBool:bvalue]  forKey:subkey];
                            
                            
                        }
                        else if ([subpro isEqualToString:@"__NSArrayI"]) {
                            NSString *ass=[cell_value str];
                            NSArray *aar=[ass componentsSeparatedByString:@","] ;
                            
                            if ([aar count]==1) {
                                [subdic setObject:[NSArray arrayWithObjects: nil]  forKey:subkey];
                            }
                            else{
                                [subdic setObject:aar  forKey:subkey];
                            }
                        }
                        else{
                            //存入資料
                            [subdic setObject:[cell_value str] forKey:subkey];
                            
                            
                        }
                    }
                    
                    
                }
                
                
                [retdic  addObject: subdic  ];
                [subdic release];
            }
            //NSLog(@"retdic=%@",retdic);
            
            
            
        }
        
        
        
        
    }
    return retdic;
    
    
    /*
    NSMutableArray *temp_table_column_array=[[[NSMutableArray alloc] init] autorelease];    
    
    //int indx_column;
    //indx_column=0;
    
    //標記：加入一個走勢圖按下右鍵的選項功能 5.實作宣告     
    NSMutableDictionary *dic;
    
    //a.指標 Chart_Indicator_1 
    {
        //Chart_Indicator_MA
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_MA forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MA forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_MA_1,CL_his_data_indicator_MA_2,CL_his_data_indicator_MA_3,CL_his_data_indicator_MA_4,CL_his_data_indicator_MA_5, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
             
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];        
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
              
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }  
        //Chart_Indicator_KD
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_KD forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_KD forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_indicator_KD_K,CL_his_data_indicator_KD_K,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isHidden_2];
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_0];        
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_1];        
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_2]; 
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_3];         
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_4];          
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }  
        //Chart_Indicator_MACD
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_MACD forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MACD forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_MACD_MACD,CL_his_data_indicator_MACD_DIF,CL_his_data_indicator_MACD_DF, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isHidden_3];
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_0];        
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_1];        
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_2]; 
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_3];         
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_4];          
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }
        //Chart_Indicator_VOL 當成初始值 所以圖1,2,3 都不隱藏
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_VOL forKey:Chart_Data_main_key];
            
            //計算方法
            [dic setObject:Defaults_Calculate_VOL forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_indicator_VOL_1,CL_his_data_indicator_VOL_2,CL_his_data_indicator_VOL_3,CL_his_data_indicator_VOL_4,CL_his_data_indicator_VOL_5 ,nil] forKey:Chart_Data_hisdata_calculate_field_show];
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isHidden_1];
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }
        
        
        
        //Chart_Indicator_MESA1
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_MESA1 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MESA1 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_MESA1_MAMA,CL_his_data_indicator_MESA1_FAMA, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }          
        //Chart_Indicator_MESA2
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_MESA2 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MESA2 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_MESA2_MAMA,CL_his_data_indicator_MESA2_FAMA, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }   
        //Chart_Indicator_MESA3
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_MESA3 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MESA3 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_MESA3_MAMA,CL_his_data_indicator_MESA3_FAMA, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }         
        //Chart_Indicator_LF1
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_LF1 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_LF1 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_LF1_Long_StopPrice,CL_his_data_indicator_LF1_Short_StopPrice, nil]forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }        
        //Chart_Indicator_LF2
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_LF2 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_LF2 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_LF2_Long_StopPrice,CL_his_data_indicator_LF2_Short_StopPrice, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }    
        //Chart_Indicator_LF3
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Indicator_LF3 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_LF3 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_indicator_LF3_Long_StopPrice,CL_his_data_indicator_LF3_Short_StopPrice, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Indicator_1 forKey:Chart_Data_classify];
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];         
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }            
        
    }
    
    //b.訊號 Chart_Signal_2
    {
       //Chart_Signal_MA
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_MA forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MA forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_MA_BS,CL_his_data_signal_MA_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }  
        //Chart_Signal_KD
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_KD forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_KD forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_KD_BS,CL_his_data_signal_KD_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_0];        
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_1];        
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_2]; 
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_3];         
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_4];            
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        } 
        //Chart_Signal_MACD
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_MACD forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MACD forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_MACD_BS,CL_his_data_signal_MACD_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_0];        
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_1];        
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_2]; 
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_3];         
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_4];            
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }         
        //Chart_Signal_MESA1
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_MESA1 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MESA1 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_MESA1_BS,CL_his_data_signal_MESA1_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }   
        //Chart_Signal_MESA2
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_MESA2 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MESA2 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_MESA2_BS,CL_his_data_signal_MESA2_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }         
        //Chart_Signal_MESA3
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_MESA3 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_MESA3 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_MESA3_BS,CL_his_data_signal_MESA3_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }   
        //Chart_Signal_LF1
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_LF1 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_LF1 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_LF1_BS,CL_his_data_signal_LF1_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }         
        //Chart_Signal_LF2
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_LF2 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_LF2 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_LF2_BS,CL_his_data_signal_LF2_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        } 
        //Chart_Signal_LF3
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Signal_LF3 forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_LF3 forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_LF3_BS,CL_his_data_signal_LF3_State,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Signal_2 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_0];
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_1];
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_2];
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_3];
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_4];
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }           
        
        
    }
   
    //c.基本資料 Chart_Fundmental_3
    {
        //Chart_Fundmental_EPS
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Fundmental_EPS forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_Fundmental_EPS forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects:CL_his_data_Fundmental_EPS, nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Fundmental_3 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_0];        
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_1];        
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_2]; 
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_3];         
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_4];            
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }          
         
    }
    
    //d.籌碼 Chart_Choma_4
    {
        //Chart_Choma_foreign
        {
            dic=[[NSMutableDictionary alloc] init];
            
            //主key
            [dic setObject:Chart_Choma_foreign forKey:Chart_Data_main_key];        
            
            //計算方法 
            [dic setObject:Defaults_Calculate_Choma_foreign forKey:Chart_Data_hisdata_calculate_method];
            
            //計算方法顯示哪些計算過後的欄位
            [dic setObject:[NSArray arrayWithObjects: CL_his_data_signal_Choma_foreign,nil] forKey:Chart_Data_hisdata_calculate_field_show]; 
            
            //分類方法
            [dic setObject:Chart_Choma_4 forKey:Chart_Data_classify];        
            
            //chart_0是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_0];        
            //chart_1是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_1];         
            //chart_2是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_2];         
            //chart_3是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_3];         
            //chart_4是否隱藏
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isHidden_4];  
            
            //chart_0是否使用
            [dic setObject:[NSNumber numberWithBool:NO ] forKey:Chart_Data_isUsed_0];        
            //chart_1是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_1];        
            //chart_2是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_2]; 
            //chart_3是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_3];         
            //chart_4是否使用
            [dic setObject:[NSNumber numberWithBool:YES ] forKey:Chart_Data_isUsed_4];            
            
            
            [temp_table_column_array addObject:dic];
            [dic release];
            
        }   
         
    }
         
   // NSLog(@"last %i",indx_column);
    
    return temp_table_column_array;
    */
}

#pragma mark -
#pragma mark dealloc/finalize
- (void)dealloc
{
	 
    [RLChartMenuItem_data_file_path release];
   
    
	[super dealloc]; 
}
 
#pragma mark -
#pragma mark 存檔
-(void)save_data:(NSMutableArray *)tabledata{
    
    [tabledata writeToFile:RLChartMenuItem_data_file_path atomically:NO];
    
}

#pragma mark -
#pragma mark 走勢圖按下右鍵選擇選項之後傳回來的訊息整理出有哪些方法
+(void)have_to_calcultae_method{
    
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; 
    
    //1.取出走勢圖選項資料
    NSMutableArray *calculate_method_data=[NSMutableArray arrayWithContentsOfFile:[File_Name_Path RLChartMenuItem_file_nameANDpath:[prefs objectForKey:@"id_資料源"]] ];
    
    //2.找出哪些方法要計算
    NSMutableArray *hav_to_Calculate_method_by_chart=[[NSMutableArray alloc] init];
    
    for (NSMutableDictionary *dic in calculate_method_data  ) {
        //chart 0
        if ([[dic objectForKey:Chart_Data_isUsed_0] isEqualToNumber:[NSNumber numberWithBool:YES]] && [[dic objectForKey:Chart_Data_isHidden_0] isEqualToNumber:[NSNumber numberWithBool:NO]]) {
            
            if ([hav_to_Calculate_method_by_chart indexOfObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]]==NSNotFound) {
                
                [hav_to_Calculate_method_by_chart addObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]];
                
            }
            
        }
        
        //chart 1
        if ([[dic objectForKey:Chart_Data_isUsed_1] isEqualToNumber:[NSNumber numberWithBool:YES]] && [[dic objectForKey:Chart_Data_isHidden_1] isEqualToNumber:[NSNumber numberWithBool:NO]]) {
            
            if ([hav_to_Calculate_method_by_chart indexOfObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]]==NSNotFound) {
                
                [hav_to_Calculate_method_by_chart addObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]];
                
            }
            
        }
        
        //chart 2
        if ([[dic objectForKey:Chart_Data_isUsed_2] isEqualToNumber:[NSNumber numberWithBool:YES]] && [[dic objectForKey:Chart_Data_isHidden_2] isEqualToNumber:[NSNumber numberWithBool:NO]]) {
            
            if ([hav_to_Calculate_method_by_chart indexOfObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]]==NSNotFound) {
                
                [hav_to_Calculate_method_by_chart addObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]];
                
            }
            
        }
        
        
        //chart 3
        if ([[dic objectForKey:Chart_Data_isUsed_3] isEqualToNumber:[NSNumber numberWithBool:YES]] && [[dic objectForKey:Chart_Data_isHidden_3] isEqualToNumber:[NSNumber numberWithBool:NO]]) {
            
            if ([hav_to_Calculate_method_by_chart indexOfObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]]==NSNotFound) {
                
                [hav_to_Calculate_method_by_chart addObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]];
                
            }
            
        }
        
        //chart 4
        if ([[dic objectForKey:Chart_Data_isUsed_4] isEqualToNumber:[NSNumber numberWithBool:YES]] && [[dic objectForKey:Chart_Data_isHidden_4] isEqualToNumber:[NSNumber numberWithBool:NO]]) {
            
            if ([hav_to_Calculate_method_by_chart indexOfObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]]==NSNotFound) {
                
                [hav_to_Calculate_method_by_chart addObject:[dic objectForKey:Chart_Data_hisdata_calculate_method]];
                
            }
            
        }
        
        
    }
    
    //3.存入 Defaults_Calculate_method_chart_click
    [prefs setObject:hav_to_Calculate_method_by_chart forKey:Defaults_Calculate_method_chart_click];
    [prefs synchronize]; 
    
    [hav_to_Calculate_method_by_chart release];
    
    
}

#pragma mark -
#pragma mark NSCoder
- (void)encodeWithCoder:(NSCoder *)aCoder{
    
    [aCoder encodeObject:RLChartMenuItem_array_A forKey:@"PXTableObject_table_column_array"]; 
    
    [aCoder encodeObject:RLChartMenuItem_data_file_path forKey:@"PXTableObject_table_column_data_file_path"];     
    [aCoder encodeObject:datasource forKey:@"PXTableObject_datasource"];       
    
}
- (id)initWithCoder:(NSCoder *)aDecoder{
    self=[super init];
    if (self) {
        
        RLChartMenuItem_array_A=[[aDecoder decodeObjectForKey:@"PXTableObject_table_column_array"] retain];
       
        RLChartMenuItem_data_file_path=[[aDecoder decodeObjectForKey:@"PXTableObject_table_column_data_file_path"] retain];    
        
        datasource=[[aDecoder decodeObjectForKey:@"PXTableObject_datasource"] retain];        
    }
    return self;
}

#pragma mark -
#pragma mark 輸入Table_Column_Key 取出 table_column位置與參考資料位置
-(NSUInteger)index_calculatemethod_array_from_column_identfiler:(NSString *)column_identfiler{
    NSString *search;
    search=column_identfiler;                
    
    NSUInteger idx = [RLChartMenuItem_array_A  indexOfObjectPassingTest:
                      ^ BOOL (NSMutableDictionary* obj, NSUInteger idx, BOOL *stop)
                      {
                          BOOL result = ([ [obj   objectForKey:Chart_Data_hisdata_calculate_method] isEqualToString:search ]);
                          *stop = result;
                          return result;                                      
                          
                      }];                
    
    
    return idx;
    
    
}
-(NSMutableDictionary *)object_calculatemethod_array_from_column_identfiler:(NSString *)column_identfiler{
    
    NSString *search;
    search=column_identfiler;                
    
    NSUInteger idx = [RLChartMenuItem_array_A  indexOfObjectPassingTest:
                      ^ BOOL (NSMutableDictionary* obj, NSUInteger idx, BOOL *stop)
                      {
                          BOOL result = ([ [obj   objectForKey:Chart_Data_hisdata_calculate_method] isEqualToString:search ]);
                          *stop = result;
                          return result;                                      
                          
                      }];               
    
    
    if (idx ==NSNotFound) {
        return nil;      
    }
    else{
        NSMutableDictionary *obj=[ RLChartMenuItem_array_A  objectAtIndex:idx];
        return obj;
        
    }
    
    
}

@end
